#!/usr/local/perl
use strict;
use warnings;
print "Hello WORLD!\n";
#Scalars
my $animal = "cancel";
my $answer = 42;
my $chomp_str = "aaa\nbbb\nccc\n";
print $chomp_str, "\n";
if(chomp($chomp_str)) {
	print "ifif", $chomp_str, "\n";
}
print $chomp_str, "\n";
print $animal, "\n";
print 'Hello\n';
print "\nHello\n";
print "The animal is $animal\n";
print "The sequence of $answer is ",$answer * $answer, "\n";
#arrays
my @animals = ("camel", "llama", "owl");
my @numbers = (23, 42, 69);
my @mixed = ("camel", 42, 1.223);
print $animals[0], "\n";
print $animals[1], "\n";
print $mixed[$#mixed], "\n";

print join(", ", reverse "world!\n", "Hello");
print scalar reverse "\n!dlrow olleH";

#Hashes
my %fruit_color = (
	apple => "red",
	banana => "yellow"
);
print $fruit_color{"apple"}, "\n";
#2 level hash of hash structure.
my $variables = {
	scalar => {
		description => "signal item",
		sigil => '$',
		},
	array => {
		description => "ordered list of items",
		sigil => '@',
		},
	hash => {
		description => "key/value pairs",
		sigil => '%',
		},
};
print "Scalars begin with a $variables->{'scalar'}->{'sigil'}\n";

#Variable scopint
my $x = "foo";
my $some_condition = 1;
if ($some_condition) {
	my $y = "bar";
	print $x, "\n"; #print foo
	print $y, "\n"; #print bar
}
print $x, "\n"; #print foo
#print $y, "\n"; #prints nothing; $y has fallen out of scope.
print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
$_ = "huge, scaly, green, dinosaur";
s/,.*een//;
print "aaaaaaaaa=[", $_, "]\n";
$_ = "huge, scaly, green, dinosaur, GREEN, green, csaly, greenxx";
s/green/ddDD/;
print "aaaaaaaaa=[", $_, "]\n";
print "222222222222222222222222222222222222222222222\n";
$_ = "Hello there, neighbor!";
my($first, $second, $third) = /(\S+) (\S+), (\S+)/;
print "$second is my $third\n";


